/*
2022-2-27 
https://leetcode-cn.com/problems/minimum-time-to-complete-trips/
*/
class Solution {
public:
    long long minimumTime(vector<int>& time, int totalTrips) {
        sort(time.begin(),time.end());
        int res=0;
        long long l=0,r=1e14;
        while(l<r)
        {
            long long temp=0;
            long long mid=(l+r)>>1;
            for(auto t:time) temp+=mid/t;
            if(temp>=totalTrips) r=mid;
            else l=mid+1;
        }
        return l;
    }
};
